import request from "@/plugins/axios";

const API_PREFIX = '/api/question'

export function getQuestions({ page, limit, sortBy, keyword }) {
  const params = { page, limit, sortBy, keyword }
  return request.get(`${API_PREFIX}/list`, { params })
}

export function getQuestionByQuestionId(questionId) {
  return request.get(`${API_PREFIX}/byQuestionId`, { params: { questionId } })
}

export function ask(content) {
  const data = { content }
  return request.post(`${API_PREFIX}/ask`, data)
}

export function deleteQuestion(questionId) {
  const data = { questionId }
  return request.post(`${API_PREFIX}/delete`, data)
}

export function editQuestion({ questionId, content }) {
  const data = { questionId, content }
  return request.post(`${API_PREFIX}/edit`, data)
}
